<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <title>AI+应用设计创新大赛</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!--====== Favicon Icon ======-->
    <link rel="shortcut icon" href="/images/favicon.png" type="image/png">
    <!--====== Bootstrap CSS ======-->
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <!--====== default CSS ======-->
    <link rel="stylesheet" href="/css/default.css">
    <link rel="stylesheet" href="/font/bootstrap-icons.css">

    <link rel="stylesheet" href="/js/layui/css/layui.css">
    <!--====== Style CSS ======-->
    <link rel="stylesheet" href="/css/style.css">
    <style>
        #content{
            width: 100%;
            padding: 10px;
        }
    </style>
</head>
<body>
    <input type="hidden" id="groundId" th:value="${groundId}">
    <div class="container">
        <div class="row">
            <div id="content">
            </div>
        </div>
    </div>

    <!--====== Jquery js ======-->
    <script src="/js/jquery-1.12.4.min.js"></script>
    <script src="/js/modernizr-3.7.1.min.js"></script>

    <!--====== Bootstrap js ======-->
    <script src="/js/bootstrap.min.js"></script>

    <script src="/js/sweetalert.min.js"></script>
    <script src="/js/jquery-validate.js"></script>

    <!--====== layerUI js ======-->
    <script src="/js/layui/layui.js"></script>

    <script src="/js/common.js"></script>
    <script type="text/javascript" th:inline="javascript">
        $(document).ready(function(){
            const groundId = $("#groundId").val();
            layui.use(function(){
                $.ajax({
                    url: '/teamOrder/order/' + groundId,
                    type: 'GET',
                    success: function (data) {
                        // 清空表格内容
                        $('#content').empty();
                        // 根据获取到的数据重新构建表格内容
                        let contentHtml = '<div class="layui-col-xs12 layui-col-sm6 layui-col-md4" style="margin-bottom: 15px">' +
                            '<div class="layui-card">';
                        data.data.forEach(function (info) {
                            contentHtml += '<a href="/uis/scoreUI?groundId=' + groundId +'&userId='+ info.user.id + '" >'+
                            '<div class="layui-card-header">' + info.sort + ' 姓名：' + info.user.name + ' 手机号：' + info.user.phone +'</div>';
                            if(info.team != null){
                                contentHtml += '<div class="layui-card-body">' +
                                '<p>赛区:' + info.user.areaName + '</p>' +
                                '<p>团队名称:' + info.team.teamName + '</p>' +
                                '<p style="color: red;">' + (info.isScore === 1?"已评分":"未评分") + '</p>' +
                                '</div>';
                            }else{
                                contentHtml += '<div class="layui-card-body">' +
                                    '<p>赛区:' + info.user.areaName + '</p>' +
                                    '<p>团队名称: 无</p>' +
                                    '<p style="color: red;">' + (info.isScore === 1?"已评分":"未评分") + '</p>' +
                                    '</div>';
                            }
                            contentHtml += '</a>'
                        });
                        contentHtml += '</div></div>';
                        $('#content').html(contentHtml);
                    },
                    error: function (error) {
                        layer.msg('获取数据失败：' + error.responseText);
                    }
                });
            });
        })
    </script>
</body>
</html>
